package com.cf.expensetracker.command;

import com.beust.jcommander.Parameter;
import com.beust.jcommander.ParameterException;
import com.beust.jcommander.Parameters;
import lombok.Data;

/**
 * Copyright(C) 2025- com.cf
 * FileName:    UpdateCmd
 * Author:      cf
 * Date:        2025/1/22 11:46
 * Description: Update command
 */
@Data
@Parameters(commandNames = "update", commandDescription = "Update expense")
public class UpdateCmd {
    @Parameter(names = "--id", description = "Id of the expense", required = true, order = 0)
    private Integer id;

    @Parameter(names = "--description", description = "Description of the expense", required = true, order = 1)
    private String description;

    @Parameter(names = "--amount", description = "Amount of the expense", required = true, order = 2)
    private Double amount;

    @Parameter(names = "--category", description = "Category of the expense", order = 3)
    private String category;

    public void validate() throws ParameterException {
        if (amount < 0) {
            throw new ParameterException("The amount can not be negative.");
        }
    }
}
